package com.bobo.rbac.auth.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Date;

@Slf4j
@Component
@Aspect
public class LogAspect {

    @Pointcut(value = "@annotation(com.bobo.rbac.auth.ann.LogAnn)")
    public void pt(){

    }

    //环绕通知
    @Around(value = "pt()")
    public Object log(ProceedingJoinPoint pjp) throws Throwable {
        Object[] args = pjp.getArgs();
        String argsStr = Arrays.toString(args);
        log.info("args======>："+argsStr);
        String methodName = pjp.getSignature().getName();
        log.info("methodName=====>："+methodName);
        String className = pjp.getTarget().getClass().getSimpleName();
        log.info("className=====>："+className);
        log.info("系统时间："+new Date());
        Object proceed = pjp.proceed();
        return proceed;
    }

}
